form').each(function(){
var $form=$(this);
wpcf7.initForm($form);
if(wpcf7.cached){
wpcf7.refill($form);
}});
});
wpcf7.getId=function(form){
return parseInt($('input[name="_wpcf7"]', form).val(), 10);
};
wpcf7.initForm=function(form){
var $form=$(form);
wpcf7.setStatus($form, 'init');
$form.submit(function(event){
if(! wpcf7.supportHtml5.placeholder){
$('[placeholder].placeheld', $form).each(function(i, n){
$(n).val('').removeClass('placeheld');
});
}
if(typeof window.FormData==='function'){
wpcf7.submit($form);
event.preventDefault();
}});
$('.wpcf7-submit', $form).after('');
wpcf7.toggleSubmit($form);
$form.on('click', '.wpcf7-acceptance', function(){
wpcf7.toggleSubmit($form);
});
$('.wpcf7-exclusive-checkbox', $form).on('click', 'input:checkbox', function(){
var name=$(this).attr('name');
$form.find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false);
});
$('.wpcf7-list-item.has-free-text', $form).each(function(){
var $freetext=$(':input.wpcf7-free-text', this);
var $wrap=$(this).closest('.wpcf7-form-control');
if($(':checkbox, :radio', this).is(':checked')){
$freetext.prop('disabled', false);
}else{
$freetext.prop('disabled', true);
}
$wrap.on('change', ':checkbox, :radio', function(){
var $cb=$('.has-free-text', $wrap).find(':checkbox, :radio');
if($cb.is(':checked')){
$freetext.prop('disabled', false).focus();
}else{
$freetext.prop('disabled', true);
}});
});
if(! wpcf7.supportHtml5.placeholder){
$('[placeholder]', $form).each(function(){
$(this).val($(this).attr('placeholder'));
$(this).addClass('placeheld');
$(this).focus(function(){
if($(this).hasClass('placeheld')){
$(this).val('').removeClass('placeheld');
}});
$(this).blur(function(){
if(''===$(this).val()){
$(this).val($(this).attr('placeholder'));
$(this).addClass('placeheld');
}});
});
}
if(wpcf7.jqueryUi&&! wpcf7.supportHtml5.date){
$form.find('input.wpcf7-date[type="date"]').each(function(){
$(this).datepicker({
dateFormat: 'yy-mm-dd',
minDate: new Date($(this).attr('min')),
maxDate: new Date($(this).attr('max'))
});
});
}
if(wpcf7.jqueryUi&&! wpcf7.supportHtml5.number){
$form.find('input.wpcf7-number[type="number"]').each(function(){
$(this).spinner({
min: $(this).attr('min'),
max: $(this).attr('max'),
step: $(this).attr('step')
});
});
}
wpcf7.resetCounter($form);
$form.on('change', '.wpcf7-validates-as-url', function(){
var val=$.trim($(this).val());
if(val
&& ! val.match(/^[a-z][a-z0-9.+-]*:/i)
&& -1!==val.indexOf('.')){
val=val.replace(/^\/+/, '');
val='http://' + val;
}
$(this).val(val);
});
};
wpcf7.submit=function(form){
if(typeof window.FormData!=='function'){
return;
}
var $form=$(form);
$('.ajax-loader', $form).addClass('is-active');
wpcf7.clearResponse($form);
var formData=new FormData($form.get(0));
var detail={
id: $form.closest('div.wpcf7').attr('id'),
status: 'init',
inputs: [],
formData: formData
};
$.each($form.serializeArray(), function(i, field){
if('_wpcf7'==field.name){
detail.contactFormId=field.value;
}else if('_wpcf7_version'==field.name){
detail.pluginVersion=field.value;
}else if('_wpcf7_locale'==field.name){
detail.contactFormLocale=field.value;
}else if('_wpcf7_unit_tag'==field.name){
detail.unitTag=field.value;
}else if('_wpcf7_container_post'==field.name){
detail.containerPostId=field.value;
}else if(field.name.match(/^_/)){
}else{
detail.inputs.push(field);
}});
wpcf7.triggerEvent($form.closest('div.wpcf7'), 'beforesubmit', detail);
var ajaxSuccess=function(data, status, xhr, $form){
detail.id=$(data.into).attr('id');
detail.status=data.status;
detail.apiResponse=data;
switch(data.status){
case 'init':
wpcf7.setStatus($form, 'init');
break;
case 'validation_failed':
$.each(data.invalid_fields, function(i, n){
$(n.into, $form).each(function(){
wpcf7.notValidTip(this, n.message);
$('.wpcf7-form-control', this).addClass('wpcf7-not-valid');
$('[aria-invalid]', this).attr('aria-invalid', 'true');
});
});
wpcf7.setStatus($form, 'invalid');
wpcf7.triggerEvent(data.into, 'invalid', detail);
break;
case 'acceptance_missing':
wpcf7.setStatus($form, 'unaccepted');
wpcf7.triggerEvent(data.into, 'unaccepted', detail);
break;
case 'spam':
wpcf7.setStatus($form, 'spam');
wpcf7.triggerEvent(data.into, 'spam', detail);
break;
case 'aborted':
wpcf7.setStatus($form, 'aborted');
wpcf7.triggerEvent(data.into, 'aborted', detail);
break;
case 'mail_sent':
wpcf7.setStatus($form, 'sent');
wpcf7.triggerEvent(data.into, 'mailsent', detail);
break;
case 'mail_failed':
wpcf7.setStatus($form, 'failed');
wpcf7.triggerEvent(data.into, 'mailfailed', detail);
break;
default:
wpcf7.setStatus($form,
'custom-' + data.status.replace(/[^0-9a-z]+/i, '-')
);
}
wpcf7.refill($form, data);
wpcf7.triggerEvent(data.into, 'submit', detail);
if('mail_sent'==data.status){
$form.each(function(){
this.reset();
});
wpcf7.toggleSubmit($form);
wpcf7.resetCounter($form);
}
if(! wpcf7.supportHtml5.placeholder){
$form.find('[placeholder].placeheld').each(function(i, n){
$(n).val($(n).attr('placeholder'));
});
}
$('.wpcf7-response-output', $form)
.html('').append(data.message).slideDown('fast');
$('.screen-reader-response', $form.closest('.wpcf7')).each(function(){
var $response=$(this);
$response.html('').append(data.message);
if(data.invalid_fields){
var $invalids=$('');
$.each(data.invalid_fields, function(i, n){
if(n.idref){
var $li=$('').append($('').attr('href', '#' + n.idref).append(n.message));
}else{
var $li=$('').append(n.message);
}
$invalids.append($li);
});
$response.append($invalids);
}
$response.focus();
});
if(data.posted_data_hash){
$form.find('input[name="_wpcf7_posted_data_hash"]').first()
.val(data.posted_data_hash);
}};
$.ajax({
type: 'POST',
url: wpcf7.apiSettings.getRoute('/contact-forms/' + wpcf7.getId($form) + '/feedback'),
data: formData,
dataType: 'json',
processData: false,
contentType: false
}).done(function(data, status, xhr){
ajaxSuccess(data, status, xhr, $form);
$('.ajax-loader', $form).removeClass('is-active');
}).fail(function(xhr, status, error){
var $e=$('').text(error.message);
$form.after($e);
});
};
wpcf7.triggerEvent=function(target, name, detail){
var event=new CustomEvent('wpcf7' + name, {
bubbles: true,
detail: detail
});
$(target).get(0).dispatchEvent(event);
};
wpcf7.setStatus=function(form, status){
var $form=$(form);
var prevStatus=$form.data('status');
$form.data('status', status);
$form.addClass(status);
if(prevStatus&&prevStatus!==status){
$form.removeClass(prevStatus);
}}
wpcf7.toggleSubmit=function(form, state){
var $form=$(form);
var $submit=$('input:submit', $form);
if(typeof state!=='undefined'){
$submit.prop('disabled', ! state);
return;
}
if($form.hasClass('wpcf7-acceptance-as-validation')){
return;
}
$submit.prop('disabled', false);
$('.wpcf7-acceptance', $form).each(function(){
var $span=$(this);
var $input=$('input:checkbox', $span);
if(! $span.hasClass('optional')){
if($span.hasClass('invert')&&$input.is(':checked')
|| ! $span.hasClass('invert')&&! $input.is(':checked')){
$submit.prop('disabled', true);
return false;
}}
});
};
wpcf7.resetCounter=function(form){
var $form=$(form);
$('.wpcf7-character-count', $form).each(function(){
var $count=$(this);
var name=$count.attr('data-target-name');
var down=$count.hasClass('down');
var starting=parseInt($count.attr('data-starting-value'), 10);
var maximum=parseInt($count.attr('data-maximum-value'), 10);
var minimum=parseInt($count.attr('data-minimum-value'), 10);
var updateCount=function(target){
var $target=$(target);
var length=$target.val().length;
var count=down ? starting - length:length;
$count.attr('data-current-value', count);
$count.text(count);
if(maximum&&maximum < length){
$count.addClass('too-long');
}else{
$count.removeClass('too-long');
}
if(minimum&&length < minimum){
$count.addClass('too-short');
}else{
$count.removeClass('too-short');
}};
$(':input[name="' + name + '"]', $form).each(function(){
updateCount(this);
$(this).keyup(function(){
updateCount(this);
});
});
});
};
wpcf7.notValidTip=function(target, message){
var $target=$(target);
$('.wpcf7-not-valid-tip', $target).remove();
$('').attr({
'class': 'wpcf7-not-valid-tip',
'role': 'alert',
'aria-hidden': 'true',
}).text(message).appendTo($target);
if($target.is('.use-floating-validation-tip *')){
var fadeOut=function(target){
$(target).not(':hidden').animate({
opacity: 0
}, 'fast', function(){
$(this).css({ 'z-index': -100 });
});
};
$target.on('mouseover', '.wpcf7-not-valid-tip', function(){
fadeOut(this);
});
$target.on('focus', ':input', function(){
fadeOut($('.wpcf7-not-valid-tip', $target));
});
}};
wpcf7.refill=function(form, data){
var $form=$(form);
var refillCaptcha=function($form, items){
$.each(items, function(i, n){
$form.find(':input[name="' + i + '"]').val('');
$form.find('img.wpcf7-captcha-' + i).attr('src', n);
var match=/([0-9]+)\.(png|gif|jpeg)$/.exec(n);
$form.find('input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]').attr('value', match[ 1 ]);
});
};
var refillQuiz=function($form, items){
$.each(items, function(i, n){
$form.find(':input[name="' + i + '"]').val('');
$form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[ 0 ]);
$form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[ 1 ]);
});
};
if(typeof data==='undefined'){
$.ajax({
type: 'GET',
url: wpcf7.apiSettings.getRoute('/contact-forms/' + wpcf7.getId($form) + '/refill'),
beforeSend: function(xhr){
var nonce=$form.find(':input[name="_wpnonce"]').val();
if(nonce){
xhr.setRequestHeader('X-WP-Nonce', nonce);
}},
dataType: 'json'
}).done(function(data, status, xhr){
if(data.captcha){
refillCaptcha($form, data.captcha);
}
if(data.quiz){
refillQuiz($form, data.quiz);
}});
}else{
if(data.captcha){
refillCaptcha($form, data.captcha);
}
if(data.quiz){
refillQuiz($form, data.quiz);
}}
};
wpcf7.clearResponse=function(form){
var $form=$(form);
$form.siblings('.screen-reader-response').html('');
$('.wpcf7-not-valid-tip', $form).remove();
$('[aria-invalid]', $form).attr('aria-invalid', 'false');
$('.wpcf7-form-control', $form).removeClass('wpcf7-not-valid');
$('.wpcf7-response-output', $form).hide().empty();
};
wpcf7.apiSettings.getRoute=function(path){
var url=wpcf7.apiSettings.root;
url=url.replace(wpcf7.apiSettings.namespace,
wpcf7.apiSettings.namespace + path);
return url;
};})(jQuery);
(function (){
if(typeof window.CustomEvent==="function") return false;
function CustomEvent(event, params){
params=params||{ bubbles: false, cancelable: false, detail: undefined };
var evt=document.createEvent('CustomEvent');
evt.initCustomEvent(event,
params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype=window.Event.prototype;
window.CustomEvent=CustomEvent;
})();
!function(t){"use strict";var e=[],a=[],i={};t.fn.cf7sgWarning=function(e){var a=t(this);if(!a.is(":input"))return a;var i=t(''+e+'ok');a.after(i)},t(document).ready(function(){t("form.wpcf7-form").on("click",".confirm-button",function(e){var a=t(e.target);a.is(".cf7sg-validation-warning .confirm-button")&&a.parent().remove()});var e=t("div.cf7-smart-grid.has-table form.wpcf7-form");e.length&&(t(".container.cf7-sg-table",e).each(function(){var e=t(this);if(e[0].hasAttribute("id")){var a=t('').attr("name",e.attr("id"));e.prepend(a)}var i=t(".row.cf7-sg-table",e),s="Add Row";switch(!0){case e[0].hasAttribute("data-button"):s=e.data("button");break;case i[0].hasAttribute("data-button"):s=i.data("button")}i.find(":input").each(function(){var e=t(this),a=e.attr("name");a.length>0&&e.addClass("cf7sg-"+a.replace("[]",""))});var n=e.next(".container.cf7-sg-table-footer");n.length>0?(n.detach(),e.after(n),n.after('")):e.after('"),i.attr("data-row","0"),(i=i.clone().addClass("cf7-sg-cloned-table-row")).attr("data-row","-1"),e.append(i.hide()),t(":input",i).prop("disabled",!0),i.append(''),e.trigger("sgTableReady")}),e.click(".container",function(e){var a=t(e.target);if(a.is("div.cf7-sg-table-button a")){if((a=a.parent()).hasClass("disabled"))return!1;(i=a.prev(".container")).is(".cf7-sg-table-footer")&&(i=i.prev(".container")),i.cf7sgCloneRow()}else if(a.is(".cf7-sg-table .row-control .dashicons")){var i=a.closest(".container");a.closest(".row.cf7-sg-table").remove();var s=i.children(".row.cf7-sg-table").not(".cf7-sg-cloned-table-row").length;i.trigger("sgRowDeleted");var n=i.children(".cf7sg-tracker-field");n.length&&n.val(s)}}));var a=t("div.cf7-smart-grid.has-validation form.wpcf7-form");a.length&&(t('input[type="number"][class*="sgv-"]',a).each(function(){var e=t(this),a=e.attr("value");e.data("current",a)}),a.change('input[type="number"]',function(e){if(t(e.target).is('input[type="number"]')){var a=t(e.target),i=a.data("current"),s=!1;switch(!0){case 0==a.val()&&a.is(".sgv-no-zero"):a.after('Value cannot be zero'),a.val(i),s=!0;break;case 0>a.val()&&a.is(".sgv-no-negative"):a.after('Value cannot be negative'),a.val(i),s=!0;break;case""==a.val()&&a.hasClass("sgv-not-empty"):a.after('Value cannot be empty'),a.val(i),s=!0}s&&a.next("span.cf7sg-validation-warning").delay(3e3).fadeOut("slow").remove()}}));var s=t("div.cf7-smart-grid.has-tabs form.wpcf7-form");s.length&&(i={},t(".cf7-sg-tabs",s).each(function(){var e=t(this);e.tabs();var a=e.children(".cf7-sg-tabs-list");if(1==a.children("li").length){a.after('');var s=e.children(".cf7-sg-tabs-panel").first(),n=t('').attr("name",s.attr("id"));e.prepend(n),s.find(":input").each(function(){var e=t(this);if(!e.is(".cf7-sg-table :input")){var a=e.attr("name");a.length>0&&e.addClass("cf7sg-"+a.replace("[]",""))}});var c=t("").append(s.clone());t(":input",c).prop("disabled",!0),i[s.attr("id")]=c.html()}}),s.trigger("sgTabsReady"),s.click("ul.ui-tabs-nav li",function(e){var a=t(e.target),i=a.closest(".cf7-sg-tabs");if(a.is(".cf7sg-close-tab")){var s=a.siblings("a").attr("href"),n=!1;i.children("div"+s).remove(),a.closest("li").remove().is(".ui-state-active")&&(n=!0);var c=i.find(".cf7-sg-tabs-list li:last-child .cf7sg-close-tab");c.length>0&&c.show(),n&&i.tabs({active:0});var r=i.children(".cf7sg-tracker-field");r&&r.val(i.children(".cf7-sg-tabs-panel").length)}else a.is(".cf7sg-add-tab")&&i.cf7sgCloneTab()}));var n=t("div.cf7-smart-grid.has-nice-select form.wpcf7-form");n.length>0&&(n.filter("div.cf7_2_post form.wpcf7-form").each(function(){var e=t(this),a=e.closest("div.cf7_2_post").attr("id");a.length>0&&e.on(a,function(e){var a=t(this);t(".cf7sg-dynamic-dropdown.ui-select:enabled",a).each(function(){t(this).niceSelect()}),t(".wpcf7-form-control.nice-select:enabled",a).each(function(){t(this).niceSelect()}),a.trigger("sgNiceSelect")})}),n.not("div.cf7_2_post form.wpcf7-form").each(function(){var e=t(this);t(".cf7sg-dynamic-dropdown.ui-select:enabled",e).each(function(){t(this).niceSelect()}),t(".wpcf7-form-control.nice-select:enabled",e).each(function(){t(this).niceSelect()}),e.trigger("sgNiceSelect")}));var c=t("div.cf7-smart-grid.has-select2 form.wpcf7-form");c.length>0&&(c.filter("div.cf7_2_post form.wpcf7-form").each(function(){var e=t(this),a=e.closest("div.cf7_2_post").attr("id");a.length>0&&e.on(a,function(e){var a=t(this);t("select.wpcf7-form-control.select2:enabled",a).each(function(){var e=t(this);e.select2({tags:e.is(".tags")})}),a.trigger("sgSelect2")})}),c.not("div.cf7_2_post form.wpcf7-form").each(function(){var e=t(this);t("select.wpcf7-form-control.select2:enabled",e).each(function(){var e=t(this);e.select2({tags:e.is(".tags")})}),e.trigger("sgSelect2")}));var r=document.createElement("input");r.setAttribute("type","date");var o="date"==r.type,l=t("div.cf7-smart-grid.has-date form.wpcf7-form");l.length>0&&(l.filter("div.cf7_2_post form.wpcf7-form").each(function(){var e=t(this),a=e.closest("div.cf7_2_post").attr("id");a.length>0&&e.on(a,function(e){t("input.wpcf7-date:enabled",t(this)).each(function(){var e=t(this),a=e.attr("id");void 0===a&&(a=d(6),e.attr("id",a)),o||e.setupDatePicker()})})}),l.not("div.cf7_2_post form.wpcf7-form").each(function(){t("input.wpcf7-date:enabled",t(this)).each(function(){var e=t(this),a=e.attr("id");void 0===a&&(a=d(6),e.attr("id",a)),o||e.setupDatePicker()})}));var f=t("div.cf7-smart-grid.has-accordion form.wpcf7-form");function d(t){t||(t=5);for(var e="",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",i=0;i0&&(f.filter("div.has-toggles form.wpcf7-form").each(function(){var e=t(this),a=t(".cf7sg-collapsible.with-toggle",e);a.each(function(){var a=t(this),i=a.attr("id");void 0===i&&(i=d(6),a.attr("id",i));var s=a.data("open"),n=!1;if(void 0===s)s=!1;else switch(s){case!0:s=0,n=!0}0==e.closest("div.cf7_2_post").length&&(n||t(":input",t(this).children(".row")).prop("disabled",!0)),a.children(".cf7sg-collapsible-title").children(".toggle").setupToggle(n),t("#"+i).accordion({collapsible:!0,icons:!1,active:s,header:"> div.cf7sg-collapsible-title",heightStyle:"content",activate:function(e,a){t(this).trigger("sgContentIncrease")}})}),a.on("sgContentIncrease",function(){t(this).accordion("refresh")}),e.click(a,function(a){var i,s=t(a.target);if(s.is("span.cf7sg-title.toggled")||s.is(".toggle-on")||s.is(".toggle-off"))i=s.closest(".cf7sg-collapsible-title");else{if(!s.parent().is(".cf7sg-collapsible.with-toggle"))return;i=s}var n=i.closest(".container.cf7sg-collapsible").attr("id"),c="",r=t('input[name="_cf7sg_toggles"]',t(this)),o=!1;void 0!==n&&r.length>0&&(c=r.val().length>0?JSON.parse(r.val()):{},o=!0);var l=i.parent().data("group");l&&t('.cf7sg-collapsible.with-toggle[data-group="'+l+'"]',e).each(function(){var e=t(this),a=e.attr("id");n!==a&&0===e.accordion("option","active")&&(e.accordion("option","active",!1),t(".toggle",e).data("toggles").toggle(!1),t(".row.ui-accordion-content :input",e).prop("disabled",!0),o&&c.hasOwnProperty(a)&&delete c[a])});var f=i.children(".toggle").data("toggles");if(i.hasClass("ui-state-active")){if(f.toggle(!0),t(".row.ui-accordion-content :input",i.parent()).not(".cf7-sg-cloned-table-row :input").prop("disabled",!1),o){var d=i.clone();d.children(".toggle").remove(),c[n]=d.text().trim()+"|"+i.children(".toggle").data("on")}}else f.toggle(!1),t(".row.ui-accordion-content :input",i.parent()).each(function(){var e=this.value;t(this).val(e.trim()).prop("disabled",!0)}),o&&c.hasOwnProperty(n)&&delete c[n];void 0!==n&&r.length>0&&r.val(JSON.stringify(c))})}),f.each(function(){t(".cf7sg-collapsible",t(this)).not(".cf7sg-collapsible.with-toggle").each(function(){var e=t(this),a=e.attr("id");void 0===a&&(a=d(6),e.attr("id",a));var i=e.data("open");if(void 0===i)i=!1;else switch(i){case!0:i=0}t("#"+a).accordion({collapsible:!0,active:i,heightStyle:"content",header:"> div.cf7sg-collapsible-title",activate:function(e,a){t(this).trigger("sgContentIncrease")}}),e.on("sgContentIncrease",function(){t(this).accordion("refresh")})})}),f.trigger("sgCollapsibleRowsReady")),t("div.cf7_2_post div.cf7-smart-grid.has-toggles form.wpcf7-form").each(function(){var e=t(this),a=e.closest("div.cf7_2_post").attr("id");a.length>0&&e.on(a,function(e){t(".cf7sg-collapsible.with-toggle",t(this)).each(function(){var e=t(this),a=e.attr("id");void 0===cf7sg.toggles_status||void 0===cf7sg.toggles_status[a]?t(".row.ui-accordion-content :input",e).prop("disabled",!0):e.children(".cf7sg-collapsible-title").trigger("click")})})}),t("div.cf7-smart-grid form.wpcf7-form").trigger("cf7SmartGridReady"),t("div.cf7-smart-grid").on("wpcf7:invalid",".wpcf7",function(e,a){t(e.target);for(var i in a.inputs){var s=a.inputs[i].name,n=t(':input[name="'+s+'"]').closest(".cf7sg-collapsible");n.length>0&&n.accordion("option","active",0)}}),t("div.cf7-smart-grid .wpcf7-submit").after('").parent().addClass("cf7sg-popup"),t("div.cf7-smart-grid").on("sgRowAdded",".container.cf7-sg-table",function(e,a){var i,s,n=t(this);if(void 0===(i=n.data("max"))||0==i)return!1;--i==a&&(s=''+cf7sg.max_table_rows+"",n.next(".cf7-sg-table-button").addClass("disabled").prepend(s))}),t("div.cf7-smart-grid").on("sgRowDeleted",".container.cf7-sg-table",function(e){var a,i=t(this);if(void 0===(a=i.data("max"))||0==a)return!1;i.next(".cf7-sg-table-button").removeClass("disabled").children(".max-limit").remove()})}),t.fn.setupDatePicker=function(){var e=t(this);if(!e.is(".wpcf7-date:enabled"))return e;var a="",i="",s=e.attr("min");void 0===s?s=null:a=(s=new Date(s)).getFullYear();var n=e.attr("max");return void 0===n?n=null:i=(n=new Date(n)).getFullYear(),e.datepicker("destroy"),e.datepicker({defaultDate:e.val(),dateFormat:"yy-mm-dd",minDate:s,maxDate:n,changeMonth:!0,changeYear:!0}),a>0&&i>0?e.datepicker("option","yearRange",a+":"+i):a>0?e.datepicker("option","yearRange",a+":c+20"):i>0&&e.datepicker("option","yearRange","c-20:"+i),e},t.fn.cf7sgCloneRow=function(e){void 0===e&&(e=!0);var a=t(this),i="";if(a.is(".cf7-sg-table-footer")&&(i=a,a=a.closest(".container.cf7-sg-table")),!a.is(".container.cf7-sg-table"))return a;var s=a.children(".row.cf7-sg-table").length-1,n=t(".cf7-sg-cloned-table-row",a),c=n.clone();c.removeClass("cf7-sg-cloned-table-row").attr("data-row",s),i.length>0?i.before(c.show()):n.before(c.show()),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var a=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>a.length)&&(e=a.length),e-=t.length;var i=a.indexOf(t,e);return-1!==i&&i===e}),t(":input",c).each(function(){var a=t(this);a.prop("disabled",!1);var i=a.attr("name"),n="";i.endsWith("[]")&&(i=i.replace("[]",""),n="[]"),a.attr("name",i+"_row-"+s+n),a.closest("span.wpcf7-form-control-wrap").removeClass(i).addClass(i+"_row-"+s),a.is("select.ui-select")&&e&&a.niceSelect(),a.is("select.nice-select")&&e&&a.niceSelect(),a.is("select.select2")&&e&&(a.select2({tags:a.is(".tags")}),a.trigger("sgSelect2"))}),a.trigger("sgContentIncrease"),a.trigger("sgRowAdded",s);var r=a.children(".cf7sg-tracker-field");return r.length&&r.val(s+1),a},t.fn.cf7sgCloneTab=function(e){var a=t(this);if(void 0===e&&(e=!0),!a.is("div.cf7-sg-tabs"))return a;var s=a.children(".cf7-sg-tabs-list"),n=s.children("li").length+1,c=a.children(".cf7-sg-tabs-panel").first().attr("id"),r=c+"-"+n,o=s.children("li").first().clone();o.find("a").attr("href","#"+r).text(o.text()+" ("+n+")"),o.append(''),o.removeClass("ui-tabs-active ui-state-active"),s.find("li .cf7sg-close-tab").hide(),s.append(o);var l=t(i[c]);l.attr("id",r),t(":input",l).each(function(){var a=t(this),i=a.is(".cf7-sg-cloned-table-row :input");i||a.prop("disabled",!1);var s=a.attr("name"),c="";s.endsWith("[]")&&(s=s.replace("[]",""),c="[]"),a.attr("name",s+"_tab-"+(n-1)+c),a.closest("span.wpcf7-form-control-wrap").removeClass(s).addClass(s+"_tab-"+(n-1)),!i&&a.is("select.ui-select")&&e&&a.niceSelect(),!i&&a.is("select.nice-select")&&e&&a.niceSelect(),!i&&a.is("select.select2")&&e&&(a.select2({tags:a.is(".tags")}),a.trigger("sgSelect2"))}),a.append(l),l.find("ul.ui-tabs-nav li a").each(function(){var e=t(this);r=e.attr("href"),e.attr("href",r+"-"+n),e.closest("ul.ui-tabs-nav").siblings("div"+r).attr("id",r.substring(1)+"-"+n)}),t(".cf7-sg-tabs",l).each(function(){t(this).tabs()}),t(".cf7sg-collapsible.with-toggle",l).each(function(){var a=t(this),i=a.attr("id")+"_tab-"+(n-1);a.attr("id",i);var s=a.data("group");s&&(s=s+"_tab-"+(n-1),a.attr("data-group",s));var c=a.data("open"),r=!1;if(void 0===c)c=!1;else switch(c){case!0:c=0,r=!0}t(".toggle",a).setupToggle(r),t(".cf7sg-collapsible",l).accordion({collapsible:!0,icons:!1,active:c,header:"> div.cf7sg-collapsible-title",heightStyle:"content",activate:function(e,a){t(this).trigger("sgContentIncrease")}}),!r&&e&&t(".row.ui-accordion-content :input",a).prop("disabled",!0)}),a.tabs("refresh"),a.tabs("option","active",-1),l.trigger("sgTabAdded",n);var f=a.children(".cf7sg-tracker-field");return f&&f.val(a.children(".cf7-sg-tabs-panel").length),a},t.fn.setupToggle=function(e){var a=t(this);if(void 0===e&&(e=!1),!a.is(".toggle"))return a;if(a.length>0){var i=a.data("on");0==i.length&&(i="Yes");var s=a.data("off");0==i.length&&(s="No"),a.toggles({drag:!1,text:{on:i,off:s},on:e})}return a},t("div.cf7-smart-grid.has-update form.wpcf7-form").on("cf7SmartGridReady",function(){var i=t(this);t.ajax({type:"POST",url:cf7sg.url,dataType:"json",data:{action:"save_grid_fields",nonce:t('input[name="_wpnonce"]',i).val(),tabs_fields:JSON.stringify(e),table_fields:JSON.stringify(a),id:t('input[name="_wpcf7"]',i).val()}}).fail(function(t,e){console.log("CF7 Smart Grid ERROR sending grid fields to server: "+e)})})}(jQuery);